package com.lrkj.smartservice.controller;

import java.util.List;

import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.core.page.TableDataInfo;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.smartservice.domain.SlideType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.smartservice.service.ISlideTypeService;

/**
 * 轮播列表Controller
 * 
 * @author yajun_ren
 * @date 2021-04-02
 */
@RestController
@RequestMapping("/smartservice/slideType")
public class SlideTypeController extends BaseController
{
    @Autowired
    private ISlideTypeService slideTypeService;

    /**
     * 查询轮播列表列表
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideType:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlideType slideType)
    {
        startPage();
        List<SlideType> list = slideTypeService.selectSlideTypeList(slideType);
        return getDataTable(list);
    }

    /**
     * 导出轮播列表列表
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideType:export')")
    @Log(title = "轮播列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SlideType slideType)
    {
        List<SlideType> list = slideTypeService.selectSlideTypeList(slideType);
        ExcelUtil<SlideType> util = new ExcelUtil<SlideType>(SlideType.class);
        return util.exportExcel(list, "slideType");
    }

    /**
     * 获取轮播列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideType:query')")
    @GetMapping(value = "/{slideTypeId}")
    public AjaxResult getInfo(@PathVariable("slideTypeId") String slideTypeId)
    {
        return AjaxResult.success(slideTypeService.selectSlideTypeById(slideTypeId));
    }

    /**
     * 新增轮播列表
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideType:add')")
    @Log(title = "轮播列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlideType slideType)
    {
        return toAjax(slideTypeService.insertSlideType(slideType));
    }

    /**
     * 修改轮播列表
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideType:edit')")
    @Log(title = "轮播列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlideType slideType)
    {
        return toAjax(slideTypeService.updateSlideType(slideType));
    }

    /**
     * 删除轮播列表
     */
    @PreAuthorize("@ss.hasPermi('smartservice:slideType:remove')")
    @Log(title = "轮播列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{slideTypeIds}")
    public AjaxResult remove(@PathVariable String[] slideTypeIds)
    {
        return toAjax(slideTypeService.deleteSlideTypeByIds(slideTypeIds));
    }
}
